package com.ss.android.account.customview.slidingdrawer;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

import com.ss.android.account.g;
import com.ss.android.account.v2.view.AccountLoginActivity;
import com.ss.android.messagebus.SubscriptionRouter;

import inline.ScreenshotListener;

public class SuperSlidingDrawer extends ViewGroup {
    final class a implements View.OnClickListener {
        private final SuperSlidingDrawer a;

        a(SuperSlidingDrawer arg1, byte arg2) {
            this(arg1);
        }

        private a(SuperSlidingDrawer arg1) {
            this.a = arg1;

        }

        public final void onClick(View arg2) {
            if(!this.a.mLocked && (this.a.mAllowSingleTap)) {
                if(this.a.mAnimateOnClick) {
                    this.a.animateToggle();
                }
                else {
                    this.a.toggle();
                }
            }
        }
    }

    public static final class b {
        private final AccountLoginActivity a;

        public b(AccountLoginActivity arg1) {
            this.a = arg1;

        }
    }

    public static final class c {
        private final AccountLoginActivity a;

        public c(AccountLoginActivity arg1) {
            this.a = arg1;

        }

        public final void a() {
            if(!this.a.d) {
                android.support.design.a.m(this.a);
            }
        }
    }

    final class d extends Handler {
        private final SuperSlidingDrawer a;

        d(SuperSlidingDrawer arg1, byte arg2) {
            this(arg1);
        }

        private d(SuperSlidingDrawer arg1) {
            this.a = arg1;

        }

        public final void handleMessage(Message arg2) {
            switch(arg2.what) {
                case 1000: {
                    this.a.doAnimation();
                    break;
                }
            }
        }
    }

    private static final int ANIMATION_FRAME_DURATION = 16;
    private static final int COLLAPSED_FULL_CLOSED = -10002;
    private static final int DEFAULT_DURATION = 300;
    private static final Interpolator DEFAULT_INTERPOLATOR;
    private static final int EXPANDED_FULL_OPEN = -10001;
    private static final float MAXIMUM_ACCELERATION = 0f;
    private static final float MAXIMUM_MAJOR_VELOCITY = 0f;
    private static final float MAXIMUM_MINOR_VELOCITY = 0f;
    private static final float MAXIMUM_TAP_VELOCITY = 0f;
    private static final int MSG_ANIMATE = 1000;
    public static final int ORIENTATION_BOTTOM_UP = 2;
    public static final int ORIENTATION_HORIZONTAL = 0;
    public static final int ORIENTATION_LEFT_TO_RIGHT = 4;
    public static final int ORIENTATION_RIGHT_TO_LEFT = 8;
    public static final int ORIENTATION_TOP_DOWN = 1;
    public static final int ORIENTATION_VERTICAL = 1;
    private static final int TAP_THRESHOLD = 6;
    private static final int VELOCITY_UNITS = 1000;
    boolean mAllowSingleTap;
    boolean mAnimateOnClick;
    private float mAnimatedAcceleration;
    private float mAnimatedVelocity;
    private boolean mAnimating;
    private long mAnimationLastTime;
    private float mAnimationPosition;
    private boolean mClosedOnTouchOutside;
    private int mCollapsedOffset;
    private View mContent;
    private int mContentHeight;
    private final int mContentId;
    private int mContentWidth;
    private long mCurrentAnimationTime;
    private boolean mDragging;
    private long mDuration;
    private boolean mExpanded;
    private int mExpandedOffset;
    private final Rect mFrame;
    private float mFromAnimationPosition;
    private View mHandle;
    private int mHandleHeight;
    private final int mHandleId;
    private int mHandleWidth;
    private final Handler mHandler;
    private Interpolator mInterpolator;
    private final Rect mInvalidate;
    private float mLastDownX;
    private float mLastDownY;
    boolean mLocked;
    private final int mMaximumAcceleration;
    private final int mMaximumMajorVelocity;
    private final int mMaximumMinorVelocity;
    private final int mMaximumTapVelocity;
    private b mOnDrawerCloseListener;
    private ScreenshotListener mOnDrawerOpenListener$39b0349f;
    private c mOnDrawerScrollListener;
    private int mOrientation;
    private final Rect mOutFrame;
    private long mStartAnimationTime;
    private final int mTapThreshold;
    private float mTotalValue;
    private int mTouchDelta;
    private boolean mTouchOutside;
    private final int mTouchSlop;
    private boolean mTracking;
    private VelocityTracker mVelocityTracker;
    private final int mVelocityUnits;
    private boolean mVertical;

    static {
        DEFAULT_INTERPOLATOR = new DecelerateInterpolator();
    }

    public SuperSlidingDrawer(Context arg2, AttributeSet arg3) {
        this(arg2, arg3, 0);
    }

    public SuperSlidingDrawer(Context arg9, AttributeSet arg10, int arg11) {
        super(arg9, arg10, arg11);
        float v6 = 0.5f;
        this.mFrame = new Rect();
        this.mOutFrame = new Rect();
        this.mInvalidate = new Rect();
        this.mHandler = new d(this, (byte) 0);
        this.mInterpolator = SuperSlidingDrawer.DEFAULT_INTERPOLATOR;
        this.mDuration = 300;
        TypedArray v3 = arg9.obtainStyledAttributes(arg10, g.a, arg11, 0);
        this.mOrientation = v3.getInt(g.h, 1);
        boolean v0 = this.mOrientation == 2 || this.mOrientation == 1 ? true : false;
        this.mVertical = v0;
        this.mCollapsedOffset = ((int)v3.getDimension(g.d, 0f));
        this.mExpandedOffset = ((int)v3.getDimension(g.f, 0f));
        this.mAllowSingleTap = v3.getBoolean(g.b, true);
        this.mAnimateOnClick = v3.getBoolean(g.c, true);
        int v0_1 = v3.getResourceId(g.g, 0);
        if(v0_1 == 0) {
            throw new IllegalArgumentException("The handle attribute is required and must refer to a valid child.");
        }

        int v2 = v3.getResourceId(g.e, 0);
        if(v2 == 0) {
            throw new IllegalArgumentException("The content attribute is required and must refer to a valid child.");
        }

        if(v0_1 == v2) {
            throw new IllegalArgumentException("The content and handle attributes must refer to different children.");
        }

        this.mHandleId = v0_1;
        this.mContentId = v2;
        float v0_2 = this.getResources().getDisplayMetrics().density;
        this.mTouchSlop = ViewConfiguration.get(this.getContext()).getScaledTouchSlop();
        this.mTapThreshold = ((int)(6f * v0_2 + v6));
        this.mMaximumTapVelocity = ((int)(100f * v0_2 + v6));
        this.mMaximumMinorVelocity = ((int)(150f * v0_2 + v6));
        this.mMaximumMajorVelocity = ((int)(200f * v0_2 + v6));
        this.mMaximumAcceleration = ((int)(2000f * v0_2 + v6));
        this.mVelocityUnits = ((int)(v0_2 * 1000f + v6));
        v3.recycle();
        this.setAlwaysDrawnWithCacheEnabled(false);
    }

    private void animateClose(int arg3) {
        this.prepareTracking(arg3);
        switch(this.mOrientation) {
            case 1: {
                this.performFling(arg3, ((float)(-this.mMaximumAcceleration)), true);
                break;
            }
            case 2: {
                this.performFling(arg3, ((float)this.mMaximumAcceleration), true);
                break;
            }
            case 4: {
                this.performFling(arg3, ((float)(-this.mMaximumAcceleration)), true);
                break;
            }
            case 8: {
                this.performFling(arg3, ((float)this.mMaximumAcceleration), true);
                break;
            }
        }
    }

    public void animateClose() {
        this.prepareContent();
        c v0 = this.mOnDrawerScrollListener;
        if(v0 != null) {
            v0.a();
        }

        int v0_1 = this.mVertical ? this.mHandle.getTop() : this.mHandle.getLeft();
        this.animateClose(v0_1);
    }

    private void animateOpen(int arg3) {
        this.prepareTracking(arg3);
        switch(this.mOrientation) {
            case 1: {
                this.performFling(arg3, ((float)this.mMaximumAcceleration), true);
                break;
            }
            case 2: {
                this.performFling(arg3, ((float)(-this.mMaximumAcceleration)), true);
                break;
            }
            case 4: {
                this.performFling(arg3, ((float)this.mMaximumAcceleration), true);
                break;
            }
            case 8: {
                this.performFling(arg3, ((float)(-this.mMaximumAcceleration)), true);
                break;
            }
        }
    }

    public void animateOpen() {
        this.prepareContent();
        c v0 = this.mOnDrawerScrollListener;
        if(v0 != null) {
            v0.a();
        }

        int v0_1 = this.mVertical ? this.mHandle.getTop() : this.mHandle.getLeft();
        this.animateOpen(v0_1);
        this.sendAccessibilityEvent(32);
    }

    public void animateToggle() {
        if(!this.mExpanded) {
            this.animateOpen();
        }
        else {
            this.animateClose();
        }
    }

    public void close() {
        this.closeDrawer();
        this.invalidate();
        this.requestLayout();
    }

    private void closeDrawer() {
        this.moveHandle(-10002);
        this.mContent.setVisibility(View.GONE);
        this.mContent.destroyDrawingCache();
        if(this.mExpanded) {
            this.mExpanded = false;
            if(this.mOnDrawerCloseListener != null) {
                b v0 = this.mOnDrawerCloseListener;
                SubscriptionRouter.c(new com.ss.android.account.bus.event.c());
                if(Build.VERSION.SDK_INT >= 21) {
                    v0.a.finishAfterTransition();
                }
                else {
                    v0.a.finish();
                }
            }
        }
    }

    protected void dispatchDraw(Canvas arg7) {
        Paint v5 = null;
        long v0 = this.getDrawingTime();
        View v2 = this.mHandle;
        this.drawChild(arg7, v2, v0);
        if((this.mTracking) || (this.mAnimating)) {
            Bitmap v3 = this.mContent.getDrawingCache();
            if(v3 != null) {
                switch(this.mOrientation) {
                    case 1: {
                        arg7.drawBitmap(v3, 0f, ((float)(-this.mContent.getMeasuredHeight() + v2.getTop())), v5);
                        return;
                    }
                    case 2: {
                        arg7.drawBitmap(v3, 0f, ((float)v2.getBottom()), v5);
                        return;
                    }
                    case 4: {
                        arg7.drawBitmap(v3, ((float)(-this.mContent.getMeasuredWidth() + v2.getLeft())), 0f, v5);
                        return;
                    }
                    case 8: {
                        arg7.drawBitmap(v3, ((float)v2.getRight()), 0f, v5);
                        return;
                    }
                }
                return;
            } else {
                arg7.save();
                switch(this.mOrientation) {
                    case 1: {
                        arg7.translate(0f, ((float)(v2.getTop() + -this.mContent.getMeasuredHeight())));
                        break;
                    }
                    case 2: {
                        arg7.translate(0f, ((float)(v2.getTop() - this.mExpandedOffset)));
                        break;
                    }
                    case 4: {
                        arg7.translate(((float)(v2.getLeft() + -this.mContent.getMeasuredWidth())), 0f);
                        break;
                    }
                    case 8: {
                        arg7.translate(((float)(v2.getLeft() - this.mExpandedOffset)), 0f);
                        break;
                    }
                }

                this.drawChild(arg7, this.mContent, v0);
                arg7.restore();
            }
        } else if(this.mExpanded) {
            this.drawChild(arg7, this.mContent, v0);
        }
    }

    private double distance(float arg3, float arg4, float arg5, float arg6) {
        float v0 = arg3 - arg5;
        float v1 = arg4 - arg6;
        return Math.sqrt(((double)(v0 * v0 + v1 * v1)));
    }

    void doAnimation() {
        int v0;
        int v1 = 1;
        if(this.mAnimating) {
            this.incrementAnimation();
            switch(this.mOrientation) {
                case 1: {
                    v0 = this.mAnimationPosition >= (((float)this.mContentHeight)) ? 1 : 0;
                    if(this.mAnimationPosition <= (((float)(-this.mCollapsedOffset)))) {
                        break;
                    }

                    v1 = 0;
                    break;
                }
                case 2: {
                    v0 = this.mAnimationPosition <= (((float)this.mExpandedOffset)) ? 1 : 0;
                    if(this.mAnimationPosition >= (((float)(this.mContentHeight + this.mExpandedOffset + this.mCollapsedOffset)))) {
                        break;
                    }

                    v1 = 0;
                    break;
                }
                case 4: {
                    v0 = this.mAnimationPosition >= (((float)this.mContentWidth)) ? 1 : 0;
                    if(this.mAnimationPosition <= (((float)(-this.mCollapsedOffset)))) {
                        break;
                    }

                    v1 = 0;
                    break;
                }
                case 8: {
                    v0 = this.mAnimationPosition <= (((float)this.mExpandedOffset)) ? 1 : 0;
                    if(this.mAnimationPosition >= (((float)(this.mContentWidth + this.mExpandedOffset + this.mCollapsedOffset)))) {
                        break;
                    }

                    v1 = 0;
                    break;
                }
                default: {
                    v1 = 0;
                    v0 = 0;
                    break;
                }
            }

            if(v0 != 0) {
                this.mAnimating = false;
                this.openDrawer();
                return;
            }

            if(v1 != 0) {
                this.mAnimating = false;
                this.closeDrawer();
                return;
            }

            this.moveHandle(((int)this.mAnimationPosition));
            this.mCurrentAnimationTime += 16;
            this.mHandler.sendMessageAtTime(this.mHandler.obtainMessage(1000), this.mCurrentAnimationTime);
        }
    }

    public View getContent() {
        return this.mContent;
    }

    public View getHandle() {
        return this.mHandle;
    }

    public int getRange() {
        int v0 = this.mOrientation == 1 || this.mOrientation == 2 ? this.mContentHeight + this.mCollapsedOffset : this.mContentWidth + this.mCollapsedOffset;
        return v0;
    }

    private void incrementAnimation() {
        long v0 = SystemClock.uptimeMillis() - this.mStartAnimationTime;
        if(v0 > this.mDuration) {
            v0 = this.mDuration;
        }

        this.mAnimationPosition = this.mInterpolator.getInterpolation((((float)v0)) / (((float)this.mDuration))) * this.mTotalValue + this.mFromAnimationPosition;
    }

    private void invokeScrollListener(int arg1, float arg2) {
    }

    public boolean isMoving() {
        boolean v0 = (this.mTracking) || (this.mAnimating) ? true : false;
        return v0;
    }

    public boolean isOpened() {
        return this.mExpanded;
    }

    public void lock() {
        this.mLocked = true;
    }

    private void moveHandle(int arg14) {
        Rect v2_1;
        Rect v1_1;
        int v3;
        int v2;
        int v1;
        int v0;
        int v12 = -10001;
        int v11 = -10002;
        int v10 = 4;
        View v4 = this.mHandle;
        if(this.mVertical) {
            v0 = this.mOrientation == 1 ? -this.mCollapsedOffset : this.mExpandedOffset;
            v1 = v0 - v4.getTop();
            v0 = this.mOrientation == 1 ? -this.mExpandedOffset : this.mCollapsedOffset;
            v0 = v0 + this.getBottom() - this.getTop() - this.mHandleHeight - v4.getTop();
            if(arg14 == v12) {
                if(this.mOrientation == 1) {
                    v4.offsetTopAndBottom(v0);
                }
                else {
                    v4.offsetTopAndBottom(v1);
                }

                this.invalidate();
            }
            else {
                if(arg14 == v11) {
                    if(this.mOrientation == 1) {
                        v4.offsetTopAndBottom(v1);
                    }
                    else {
                        v4.offsetTopAndBottom(v0);
                    }

                    this.invalidate();
                }else {
                    v2 = arg14 - v4.getTop();
                    v3 = this.mOrientation == 1 ? -this.mCollapsedOffset : this.mExpandedOffset;
                    if (arg14 < v3) {
                        v0 = v1;
                    } else if (v2 <= v0) {
                        v0 = v2;
                    }
                    if (v0 == 0) {
                        return;
                    }
                    v4.offsetTopAndBottom(v0);
                    v1_1 = this.mFrame;
                    v2_1 = this.mInvalidate;
                    v4.getHitRect(v1_1);
                    v2_1.set(v1_1);
                    v2_1.union(v1_1.left, v1_1.top - v0, v1_1.right, v1_1.bottom - v0);
                    if (this.mOrientation == 1) {
                        v2_1.union(0, 0, this.getWidth(), v1_1.top - v0);
                    } else {
                        v2_1.union(0, v1_1.bottom - v0, this.getWidth(), v1_1.bottom - v0 + this.mContent.getHeight());
                    }
                    this.invalidate(v2_1);
                }
            }

            if(arg14 == v12) {
                this.invokeScrollListener(this.getRange(), 1f);
                return;
            }

            if(arg14 == v11) {
                this.invokeScrollListener(0, 0f);
                return;
            }

            v1 = this.getRange();
            v0 = this.mOrientation == 1 ? v4.getTop() + this.mCollapsedOffset : v1 - (v4.getTop() - this.mExpandedOffset);
            this.invokeScrollListener(v0, (((float)v0)) / (((float)v1)));
        }
        else {
            v0 = this.mOrientation == v10 ? -this.mCollapsedOffset : this.mExpandedOffset;
            v1 = v0 - v4.getLeft();
            v0 = this.mOrientation == v10 ? -this.mExpandedOffset : this.mCollapsedOffset;
            v0 = v0 + this.getRight() - this.getLeft() - this.mHandleWidth - v4.getLeft();
            if(arg14 == v12) {
                if(this.mOrientation == v10) {
                    v4.offsetLeftAndRight(v0);
                }
                else {
                    v4.offsetLeftAndRight(v1);
                }

                this.invalidate();
            }
            else {
                if(arg14 == v11) {
                    if(this.mOrientation == v10) {
                        v4.offsetLeftAndRight(v1);
                    }
                    else {
                        v4.offsetLeftAndRight(v0);
                    }

                    this.invalidate();
                }else {
                    v2 = arg14 - v4.getLeft();
                    v3 = this.mOrientation == v10 ? -this.mCollapsedOffset : this.mExpandedOffset;
                    if (arg14 < v3) {
                        v0 = v1;
                    } else if (v2 <= v0) {
                        v0 = v2;
                    }

                    if (v0 == 0) {
                        return;
                    }

                    v4.offsetLeftAndRight(v0);
                    v1_1 = this.mFrame;
                    v2_1 = this.mInvalidate;
                    v4.getHitRect(v1_1);
                    v2_1.set(v1_1);
                    v2_1.union(v1_1.left - v0, v1_1.top, v1_1.right - v0, v1_1.bottom);
                    if (this.mOrientation == v10) {
                        v2_1.union(0, 0, v1_1.left - v0, this.getHeight());
                    } else {
                        v2_1.union(v1_1.right - v0, 0, v1_1.right - v0 + this.mContent.getWidth(), this.getHeight());
                    }
                    this.invalidate(v2_1);
                }
            }

            if(arg14 == v12) {
                this.invokeScrollListener(this.getRange(), 1f);
                return;
            }

            if(arg14 == v11) {
                this.invokeScrollListener(0, 0f);
                return;
            }

            v1 = this.getRange();
            v0 = this.mOrientation == v10 ? v4.getLeft() + this.mCollapsedOffset : v1 - (v4.getLeft() - this.mExpandedOffset);
            this.invokeScrollListener(v0, (((float)v0)) / (((float)v1)));
        }
    }

    protected void onFinishInflate() {
        super.onFinishInflate();
        this.mHandle = this.findViewById(this.mHandleId);
        if(this.mHandle == null) {
            throw new IllegalArgumentException("The handle attribute is must refer to an existing child.");
        }

        this.mHandle.setOnClickListener(new a(this, (byte) 0));
        this.mContent = this.findViewById(this.mContentId);
        if(this.mContent == null) {
            throw new IllegalArgumentException("The content attribute is must refer to an existing child.");
        }

        this.mContent.setVisibility(View.GONE);
    }

    public void onInitializeAccessibilityEvent(AccessibilityEvent arg2) {
        super.onInitializeAccessibilityEvent(arg2);
        arg2.setClassName(SuperSlidingDrawer.class.getName());
    }

    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo arg3) {
        super.onInitializeAccessibilityNodeInfo(arg3);
        if(Build.VERSION.SDK_INT >= 14) {
            arg3.setClassName(SuperSlidingDrawer.class.getName());
        }
    }

    public boolean onInterceptTouchEvent(MotionEvent arg13) {
        int v0_1;
        boolean v0 = false;
        if(!this.mLocked) {
            int v2 = arg13.getAction();
            float v3 = arg13.getX();
            float v4 = arg13.getY();
            Rect v5 = this.mFrame;
            Rect v6 = this.mOutFrame;
            View v7 = this.mHandle;
            v7.getHitRect(v5);
            switch(this.mOrientation) {
                case 1: {
                    v6.set(v5.left, v5.bottom, v5.right, this.getBottom());
                    break;
                }
                case 2: {
                    v6.set(v5.left, this.getTop(), v5.right, v5.top);
                    break;
                }
                case 4: {
                    v6.set(v5.right, v5.top, this.getRight(), v5.bottom);
                    break;
                }
                case 8: {
                    v6.set(this.getLeft(), v5.top, v5.left, v5.bottom);
                    break;
                }
            }

            if(v2 == 0) {
                this.mTouchOutside = v6.contains(((int)v3), ((int)v4));
                this.mLastDownX = v3;
                this.mLastDownY = v4;
            }

            if(!this.mTracking && !v5.contains(((int)v3), ((int)v4))) {
                return v0;
            }

            switch(v2) {
                case 0: {
                    label_29:
                    this.mDragging = false;
                    v7.setPressed(true);
                    if(!this.mAllowSingleTap) {
                        return v0;
                    }

                    this.mTracking = true;
                    this.prepareContent();
                    if(this.mOnDrawerScrollListener != null) {
                        this.mOnDrawerScrollListener.a();
                    }

                    if(this.mVertical) {
                        v0_1 = this.mHandle.getTop();
                        this.mTouchDelta = (((int)v4)) - v0_1;
                        this.prepareTracking(v0_1);
                    }
                    else {
                        v0_1 = this.mHandle.getLeft();
                        this.mTouchDelta = (((int)v3)) - v0_1;
                        this.prepareTracking(v0_1);
                    }

                    this.mVelocityTracker.addMovement(arg13);
                    v0 = true;
                    return v0;
                }
                case 2: {
                    if(this.distance(this.mLastDownX, this.mLastDownY, v3, v4) <= (((double)this.mTouchSlop))) {
                        return v0;
                    }

                    this.mTracking = true;
                    this.mDragging = true;
                    this.prepareContent();
                    if(this.mOnDrawerScrollListener != null) {
                        this.mOnDrawerScrollListener.a();
                    }

                    if(this.mVertical) {
                        v0_1 = this.mHandle.getTop();
                        this.mTouchDelta = (((int)v4)) - v0_1;
                        this.prepareTracking(v0_1);
                    }
                    else {
                        v0_1 = this.mHandle.getLeft();
                        this.mTouchDelta = (((int)v3)) - v0_1;
                        this.prepareTracking(v0_1);
                    }

                    this.mVelocityTracker.addMovement(arg13);
                    return true;
                }
                case 1: 
                case 3: {
                    this.stopTracking();
                    return v0;
                }
            }

            return v0;
        }

        return v0;
    }

    protected void onLayout(boolean arg13, int arg14, int arg15, int arg16, int arg17) {
        if(!this.mTracking) {
            int v2 = arg16 - arg14;
            int v3 = arg17 - arg15;
            View v4 = this.mHandle;
            int v5 = v4.getMeasuredWidth();
            int v6 = v4.getMeasuredHeight();
            int v1 = 0;
            int v0 = 0;
            View v7 = this.mContent;
            switch(this.mOrientation) {
                case 1: {
                    v1 = (v2 - v5) / 2;
                    v0 = this.mExpanded ? v3 - v6 - this.mExpandedOffset : -this.mCollapsedOffset;
                    v7.layout(0, 0, v7.getMeasuredWidth(), v7.getMeasuredHeight());
                    break;
                }
                case 2: {
                    v1 = (v2 - v5) / 2;
                    v0 = this.mExpanded ? this.mExpandedOffset : v3 - v6 + this.mCollapsedOffset;
                    v7.layout(0, this.mExpandedOffset + v6, v7.getMeasuredWidth(), this.mExpandedOffset + v6 + v7.getMeasuredHeight());
                    break;
                }
                case 4: {
                    v0 = this.mExpanded ? v2 - v5 - this.mExpandedOffset : -this.mCollapsedOffset;
                    v7.layout(0, 0, v7.getMeasuredWidth(), v7.getMeasuredHeight());
                    v1 = v0;
                    v0 = (v3 - v6) / 2;
                    break;
                }
                case 8: {
                    v0 = this.mExpanded ? this.mExpandedOffset : v2 - v5 + this.mCollapsedOffset;
                    v7.layout(this.mExpandedOffset + v5, 0, this.mExpandedOffset + v5 + v7.getMeasuredWidth(), v7.getMeasuredHeight());
                    v1 = v0;
                    v0 = (v3 - v6) / 2;
                    break;
                }
            }

            v4.layout(v1, v0, v1 + v5, v0 + v6);
            this.mHandleHeight = v4.getHeight();
            this.mHandleWidth = v4.getWidth();
            this.mContentHeight = v7.getHeight();
            this.mContentWidth = v7.getWidth();
        }
    }

    public void onMeasure(int arg7, int arg8) {
        int v5 = 1073741824;
        int v0 = View.MeasureSpec.getMode(arg7);
        int v1 = View.MeasureSpec.getSize(arg7);
        int v2 = View.MeasureSpec.getMode(arg8);
        int v3 = View.MeasureSpec.getSize(arg8);
        if(v0 != 0 && v2 != 0) {
            View v0_1 = this.mHandle;
            this.measureChild(v0_1, arg7, arg8);
            if(this.mVertical) {
                this.mContent.measure(View.MeasureSpec.makeMeasureSpec(v1, v5), View.MeasureSpec.makeMeasureSpec(v3 - v0_1.getMeasuredHeight() - this.mExpandedOffset, v5));
            }
            else {
                this.mContent.measure(View.MeasureSpec.makeMeasureSpec(v1 - v0_1.getMeasuredWidth() - this.mExpandedOffset, v5), View.MeasureSpec.makeMeasureSpec(v3, v5));
            }

            this.setMeasuredDimension(v1, v3);
            return;
        }

        throw new RuntimeException("SlidingDrawer cannot have UNSPECIFIED dimensions");
    }

    public boolean onTouchEvent(MotionEvent arg14) {
        float v2_1;
        int v12;
        int v2;
        boolean v0;
        if(this.mLocked) {
            v0 = true;
        }
        else {
            int v0_1 = arg14.getAction();
            if(!this.mTracking && (this.mTouchOutside)) {
                switch(v0_1) {
                    case 1: {
                        if((this.mClosedOnTouchOutside) && this.distance(arg14.getX(), arg14.getY(), this.mLastDownX, this.mLastDownY) < (((double)this.mTouchSlop))) {
                            this.animateClose();
                            return true;
                        }
                    }
                }
            }
            if(this.mTracking) {
                this.mVelocityTracker.addMovement(arg14);
                switch(v0_1) {
                    case 2: {
                        if(!this.mDragging && this.distance(this.mLastDownX, this.mLastDownY, arg14.getX(), arg14.getY()) > (((double)this.mTapThreshold))) {
                            this.mDragging = true;
                        }
                        float v0_2 = this.mVertical ? arg14.getY() : arg14.getX();
                        this.moveHandle((((int)v0_2)) - this.mTouchDelta);
                       break;
                    }
                    case 1: 
                    case 3: {
                        VelocityTracker v0_3 = this.mVelocityTracker;
                        v0_3.computeCurrentVelocity(this.mVelocityUnits);
                        float v1 = v0_3.getYVelocity();
                        float v0_2 = v0_3.getXVelocity();
                        boolean v6 = this.mVertical;
                        if(v6) {
                            v2 = v1 < 0f ? 1 : 0;
                            if(v0_2 < 0f) {
                                v0_2 = -v0_2;
                            }

                            if(v0_2 <= (((float)this.mMaximumMinorVelocity))) {
                                v12 = v2;
                                v2_1 = v0_2;
                                v0_1 = v12;
                            }else {
                                v12 = v2;
                                v2_1 = ((float) this.mMaximumMinorVelocity);
                                v0_1 = v12;
                            }
                        } else {
                            v2 = v0_2 < 0f ? 1 : 0;
                            if(v1 < 0f) {
                                v1 = -v1;
                            }
                            if(v1 > (((float)this.mMaximumMinorVelocity))) {
                                v1 = ((float)this.mMaximumMinorVelocity);
                                v12 = v2;
                                v2_1 = v0_2;
                                v0_1 = v12;
                            }else {
                                v12 = v2;
                                v2_1 = v0_2;
                                v0_1 = v12;
                            }
                        }
                        v1 = ((float)Math.hypot(((double)v2_1), ((double)v1)));
                        v0_2 = v0_1 != 0 ? -v1 : v1;
                        int v1_1 = this.mHandle.getTop();
                        v2 = this.mHandle.getLeft();
                        if((this.mAllowSingleTap) && !this.mDragging && Math.abs(v0_2) < (((float)this.mMaximumTapVelocity))) {
                            int v5 = this.mOrientation == 1 || this.mOrientation == 4 ? 1 : 0;
                            if(v6) {
                                if(v5 != 0) {
                                    if(!this.mExpanded || v1_1 <= this.getBottom() - this.getTop() - this.mExpandedOffset - this.mHandleHeight - this.mTapThreshold) {
                                        if(!this.mExpanded&& v1_1 < this.mTapThreshold + this.mExpandedOffset) {
                                            v5 = 1;
                                        }else{
                                            if (v5 != 0) {
                                                v5 = 0;
                                            } else if (!this.mExpanded || v1_1 >= this.mTapThreshold + this.mExpandedOffset) {
                                                if (!this.mExpanded && v1_1 > this.mCollapsedOffset + this.getBottom() - this.getTop() - this.mHandleHeight - this.mTapThreshold) {
                                                    v5 = 1;
                                                } else {
                                                    v5 = 0;
                                                }
                                            } else {
                                                v5 = 1;
                                            }
                                        }
                                    }else {
                                        v5 = 1;
                                    }
                                }else {
                                    if (v5 != 0) {
                                        v5 = 0;
                                    } else if (!this.mExpanded || v1_1 >= this.mTapThreshold + this.mExpandedOffset) {
                                        if (!this.mExpanded && v1_1 > this.mCollapsedOffset + this.getBottom() - this.getTop() - this.mHandleHeight - this.mTapThreshold) {
                                            v5 = 1;
                                        } else {
                                            v5 = 0;
                                        }
                                    } else {
                                        v5 = 1;
                                    }
                                }
                            } else {
                                if (v5 != 0) {
                                    if (!this.mExpanded || v2 <= this.getRight() - this.getLeft() - this.mExpandedOffset - this.mHandleWidth - this.mTapThreshold) {
                                        if (!this.mExpanded && v2 < this.mTapThreshold + this.mExpandedOffset) {
                                            v5 = 1;
                                        } else {
                                            if(v5 == 0) {
                                                if(!this.mExpanded || v2 >= this.mTapThreshold + this.mExpandedOffset) {
                                                    if(!this.mExpanded && v2 > this.mCollapsedOffset + this.getRight() - this.getLeft() - this.mHandleWidth - this.mTapThreshold) {
                                                        v5 = 1;
                                                    } else {
                                                        v5 = 0;
                                                    }
                                                }else {
                                                    v5 = 1;
                                                }
                                            }else {
                                                v5 = 0;
                                            }
                                        }
                                    } else {
                                        v5 = 1;
                                    }
                                }else{
                                    if(v5 == 0) {
                                        if(!this.mExpanded || v2 >= this.mTapThreshold + this.mExpandedOffset) {
                                            if(!this.mExpanded && v2 > this.mCollapsedOffset + this.getRight() - this.getLeft() - this.mHandleWidth - this.mTapThreshold) {
                                                v5 = 1;
                                            } else {
                                                v5 = 0;
                                            }
                                        }else {
                                            v5 = 1;
                                        }
                                    }else {
                                        v5 = 0;
                                    }
                                }
                            }

                            label_124:
                            if(v5 != 0) {
                                this.playSoundEffect(0);
                                if(this.mExpanded) {
                                    v0_1 = v6 ? v1_1 : v2;
                                    this.animateClose(v0_1);
                                }else {
                                    if (!v6) {
                                        v1_1 = v2;
                                    }
                                    this.animateOpen(v1_1);
                                }
                            }else {
                                if (!v6) {
                                    v1_1 = v2;
                                }
                                this.performFling(v1_1, v0_2, false);
                            }
                        }else {
                            if (!v6) {
                                v1_1 = v2;
                            }
                            this.performFling(v1_1, v0_2, false);
                        }
                        break;
                    }
                }
            }
            if(!this.mTracking && !this.mAnimating && !super.onTouchEvent(arg14)) {
                return false;
            }
            v0 = true;
        }

        return v0;
    }

    public void open() {
        this.openDrawer();
        this.invalidate();
        this.requestLayout();
        this.sendAccessibilityEvent(32);
    }

    private void openDrawer() {
        this.moveHandle(-10001);
        this.mContent.setVisibility(View.VISIBLE);
        if(!this.mExpanded) {
            this.mExpanded = true;
        }
    }

    private void performFling(int arg8, float arg9, boolean arg10) {
        int v6 = 1000;
        int v1 = 0;
        this.mAnimationPosition = ((float)arg8);
        this.mAnimatedVelocity = arg9;
        int v0 = this.mOrientation == 1 || this.mOrientation == 4 ? 1 : 0;
        if(!this.mExpanded) {
            if(!arg10) {
                if(v0 != 0 && arg9 >= (float) -this.mMaximumMajorVelocity || v0==0 &&arg9 <= (((float)this.mMaximumMajorVelocity))) {
                    if (v0 != 0) {
                        v0 = this.mVertical ? this.getHeight() : this.getWidth();
                        if (arg8 >= v0 / 2) {
                            v1 = 1;
                        } else if (arg9 < (((float) this.mMaximumMajorVelocity))) {

                        } else {
                            v1 = 1;
                        }
                    } else {
                        v0 = this.mVertical ? this.getHeight() : this.getWidth();
                        if (arg8 <= v0 / 2) {
                            v1 = 1;
                        } else if (arg9 > (((float) (-this.mMaximumMajorVelocity)))) {
                        } else {
                            v1 = 1;
                        }
                    }
                }
            }else{
                v1 = 1;
            }
        } else if (!arg10) {
            if (v0 != 0 && arg9 >= (float) -this.mMaximumMajorVelocity || v0 == 0 && arg9 <= (((float) this.mMaximumMajorVelocity))) {
                if (v0 != 0) {
                    v0 = this.mVertical ? this.getHeight() - (this.mHandleHeight << 1) : this.getWidth() - (this.mHandleWidth << 1);
                    if (arg8 >= v0 - this.mExpandedOffset) {
                        v1 = 1;
                    }
                    if (arg9 < (((float) this.mMaximumMajorVelocity))) {

                    } else {
                        v1 = 1;
                    }
                } else {
                    v0 = this.mVertical ? this.mHandleHeight : this.mHandleWidth;
                    if (arg8 <= v0 + this.mExpandedOffset) {
                        v1 = 1;
                    } else if (arg9 > (((float) (-this.mMaximumMajorVelocity)))) {

                    } else {
                        v1 = 1;
                    }
                }
            }
        }
        this.mFromAnimationPosition = ((float)arg8);
        switch(this.mOrientation) {
            case 1: {
                if(v1 != 0) {
                    v0 = this.mContentHeight;
                   break;
                }

                v0 = -this.mCollapsedOffset;
                break;
            }
            case 2: {
                if(v1 != 0) {
                    v0 = this.mExpandedOffset;
                    break;
                }

                v0 = this.mContentHeight + this.mExpandedOffset + this.mCollapsedOffset;
                break;
            }
            case 4: {
                if(v1 != 0) {
                    v0 = this.mContentWidth;
                    break;
                }

                v0 = -this.mExpandedOffset;
                break;
            }
            case 8: {
                if(v1 != 0) {
                    v0 = this.mExpandedOffset;
                   break;
                }

                v0 = this.mContentWidth + this.mExpandedOffset + this.mCollapsedOffset;
                break;
            }
            default: {
                v0 = arg8;
                break;
            }
        }

        this.mTotalValue = ((float)(v0 - arg8));
        long v0_1 = SystemClock.uptimeMillis();
        this.mStartAnimationTime = v0_1;
        this.mAnimationLastTime = v0_1;
        this.mCurrentAnimationTime = v0_1 + 16;
        this.mAnimating = true;
        this.mHandler.removeMessages(v6);
        this.mHandler.sendMessageAtTime(this.mHandler.obtainMessage(v6), this.mCurrentAnimationTime);
        this.stopTracking();
    }

    private void prepareContent() {
        int v1;
        int v6 = 1073741824;
        if(!this.mAnimating) {
            View v0 = this.mContent;
            if(v0.isLayoutRequested()) {
                if(this.mVertical) {
                    v1 = this.mHandleHeight;
                    v0.measure(View.MeasureSpec.makeMeasureSpec(this.getRight() - this.getLeft(), v6), View.MeasureSpec.makeMeasureSpec(this.getBottom() - this.getTop() - v1 - this.mExpandedOffset, v6));
                    if(this.mOrientation == 1) {
                        v0.layout(0, 0, v0.getMeasuredWidth(), v0.getMeasuredHeight());
                    }
                    else {
                        v0.layout(0, this.mExpandedOffset + v1, v0.getMeasuredWidth(), v1 + this.mExpandedOffset + v0.getMeasuredHeight());
                    }
                }
                else {
                    v1 = this.mHandle.getWidth();
                    v0.measure(View.MeasureSpec.makeMeasureSpec(this.getRight() - this.getLeft() - v1 - this.mExpandedOffset, v6), View.MeasureSpec.makeMeasureSpec(this.getBottom() - this.getTop(), v6));
                    if(this.mOrientation == 4) {
                        v0.layout(0, 0, v0.getMeasuredWidth(), v0.getMeasuredHeight());
                    }
                    else {
                        v0.layout(this.mExpandedOffset + v1, 0, v1 + this.mExpandedOffset + v0.getMeasuredWidth(), v0.getMeasuredHeight());
                    }
                }
            }

            v0.getViewTreeObserver().dispatchOnPreDraw();
            if(!v0.isHardwareAccelerated()) {
                v0.buildDrawingCache();
            }

            v0.setVisibility(View.GONE);
        }
    }

    private void prepareTracking(int arg7) {
        int v3 = 1000;
        this.mTracking = true;
        this.mVelocityTracker = VelocityTracker.obtain();
        int v0 = !this.mExpanded ? 1 : 0;
        if(v0 != 0) {
            this.mAnimatedAcceleration = ((float)this.mMaximumAcceleration);
            this.mAnimatedVelocity = ((float)this.mMaximumMajorVelocity);
            switch(this.mOrientation) {
                case 1: {
                    this.mAnimatedAcceleration = ((float)(-this.mCollapsedOffset));
                    break;
                }
                case 2: {
                    this.mAnimationPosition = ((float)(this.getHeight() - this.mHandleHeight + this.mCollapsedOffset - this.mExpandedOffset));
                    break;
                }
                case 4: {
                    this.mAnimationPosition = ((float)(-this.mCollapsedOffset));
                    break;
                }
                case 8: {
                    this.mAnimationPosition = ((float)(this.getWidth() - this.mHandleWidth + this.mCollapsedOffset - this.mExpandedOffset));
                    break;
                }
            }

            this.moveHandle(((int)this.mAnimationPosition));
            this.mAnimating = true;
            this.mHandler.removeMessages(v3);
            long v2 = SystemClock.uptimeMillis();
            this.mAnimationLastTime = v2;
            this.mCurrentAnimationTime = v2 + 16;
            this.mAnimating = true;
        }
        else {
            if(this.mAnimating) {
                this.mAnimating = false;
                this.mHandler.removeMessages(v3);
            }

            this.moveHandle(arg7);
        }
    }

    public void setAllowSingleTap(boolean arg1) {
        this.mAllowSingleTap = arg1;
    }

    public void setClosedOnTouchOutside(boolean arg2) {
        if(!this.isClickable()) {
            this.setClickable(true);
        }

        this.mClosedOnTouchOutside = arg2;
    }

    public void setCollapsedOffset(int arg1) {
        this.mCollapsedOffset = arg1;
    }

    public void setDuration(long arg2) {
        this.mDuration = arg2;
    }

    public void setExpandedOffset(int arg1) {
        this.mExpandedOffset = arg1;
    }

    public void setIntepolator(Interpolator arg1) {
        this.mInterpolator = arg1;
    }

    public void setOnDrawerCloseListener(b arg1) {
        this.mOnDrawerCloseListener = arg1;
    }

    public void setOnDrawerOpenListener$6c7bf504(ScreenshotListener arg1) {
        this.mOnDrawerOpenListener$39b0349f = arg1;
    }

    public void setOnDrawerScrollListener(c arg1) {
        this.mOnDrawerScrollListener = arg1;
    }

    private void stopTracking() {
        this.mHandle.setPressed(false);
        this.mTracking = false;
        this.mDragging = false;
        if(this.mVelocityTracker != null) {
            this.mVelocityTracker.recycle();
            this.mVelocityTracker = null;
        }
    }

    public void toggle() {
        if(!this.mExpanded) {
            this.openDrawer();
        }
        else {
            this.closeDrawer();
        }

        this.invalidate();
        this.requestLayout();
    }

    public void unlock() {
        this.mLocked = false;
    }
}

